<?php
/**
 * Next.php
 * 
 * @category   Naneau
 * @package    Naneau_View_Helper
 * @copyright  Copyright (c) 2007 Maurice Fonk - http://naneau.nl
 * @version    0.1
 */

/**
 * Naneau_View_Helper_Next
 * 
 * find the next item for a Zend_Db_Table_Row object
 *
 * @category   Naneau
 * @package    Naneau_View_Helper
 * @copyright  Copyright (c) 2007 Maurice Fonk - http://naneau.nl
 */
class Naneau_View_Helper_Next {

    /**
     * find the next item
     *
     * @param Zend_Db_Table_Row $row the row
     * @param string $order what to order it by
     * @return Zend_Db_Table_Row|bool
     */
    public function next($row, $order = 'id') {
        $table = $row->getTable();
        $rowset = $table->fetchAll($order . ' > ' . $row->$order, $order . ' ASC', 1);
        if ($rowset->valid()) {
            return $rowset->current();
        }
        return false;
    }
}